package com.yunheone.view.Student;

import com.yunheone.control.Studentcontrol;
import com.yunheone.mode.StudentUse;

import java.util.Scanner;
import java.util.function.BiConsumer;

/**
 * Created by Administrator on 2017/8/9 0009.
 */
public class StudentUI {
    public static int  stedentUse(){
        System.out.println ("***********学员管理系统—学员管理***********");
        System.out.println ("班级\t\t学号\t\t姓名\t\t年龄\t\t性别");
        Studentcontrol.getStudentmap ().forEach ( new BiConsumer<String, StudentUse> () {
            @Override
            public void accept(String s, StudentUse studentUse) {
                System.out.println ( studentUse.getGrade () + "\t\t" + studentUse.getId () + "\t\t" + studentUse.getName ()
                        + "\t\t" + studentUse.getAge ()+"\t\t"+studentUse.getSex () );
            }
        });
        System.out.println ( "1.添加学员    2.删除学员    3.返回主页" );
        Scanner input = new Scanner ( System.in );
        System.out.print ( "请输入操作序号：" );
        try {
            int i = input.nextInt ();
            if (i > 3 || i < 1) {
                throw new Exception ( "操作序号未识别" );
            }
            return i;
        } catch (Exception e) {
            String message = e.getMessage ();
            System.out.println ( message != null ? message : "输入不合法" );
            return stedentUse ();
        }
    }

}
